import 'package:dio/dio.dart';
import 'package:f_demo_two/pages/home/home_search_bar.dart';
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  // 1. 定义字典存储接口数据
  Map resData = {};

  // 获取首页数据
  getHomeData() async {
    Dio dio = Dio();
    final res = await dio.get(
      'http://smart-shop.itheima.net/index.php?s=/api/page/detail',
    );
    setState(() {
      resData = res.data['data']['pageData'];
    });
  }

  @override
  void initState() {
    super.initState();
    getHomeData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('智慧商城', style: TextStyle(color: Colors.white)),
        centerTitle: true,
        backgroundColor: Colors.red,
      ),
      body: ListView(children: [HomeSearchBar()]),
    );
  }
}
